<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Open a connection to an Ingres database</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.ingres-connect" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ingres_connect</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.2, PHP 5 &lt; 5.1.0, PECL ingres &gt;= 1.0.0)</p><p class="refpurpose"><span class="refname">ingres_connect</span> &mdash; <span class="dc-title">Open a connection to an Ingres database</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.ingres-connect-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>ingres_connect</strong></span>
    ([ <span class="methodparam"><span class="type">string</span> <code class="parameter">$database</code></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$username</code></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$password</code></span>
   [, <span class="methodparam"><span class="type">array</span> <code class="parameter">$options</code></span>
  ]]]] ) : <span class="type">resource</span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>ingres_connect()</strong></span> opens a connection with the
   given Ingres <code class="parameter">database</code>.
  </p>
  <p class="para">
   The connection is closed when the script ends or when
   <span class="function"><a href="ingres_close.html" class="function">ingres_close()</a></span> is called on this link.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.ingres-connect-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   If some parameters are missing, <span class="function"><strong>ingres_connect()</strong></span>
   uses the values in <var class="filename">php.ini</var> for
   <code class="parameter">ingres.default_database</code>,
   <code class="parameter">ingres.default_user</code> and
   <code class="parameter">ingres.default_password</code>.
  </p>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">database</code></dt>

     <dd>

      <p class="para">
       The database name. Must follow the syntax:
      </p>
      <p class="para">
       <var class="varname"><var class="varname">[vnode::]dbname[/svr_class]</var></var>
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">username</code></dt>

     <dd>

      <p class="para">
       The Ingres user name
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">password</code></dt>

     <dd>

      <p class="para">
       The password associated with <code class="parameter">username</code>
      </p>
     </dd>

    
    
     <dt id="function.ingres-connect.options"><code class="parameter">options</code></dt>

     <dd>

      <p class="para">
       <span class="function"><strong>ingres_connect()</strong></span> options
       <table class="doctable informaltable">
        
         <thead>
          <tr style="vertical-align: top;">
           <th>Option name</th>
           <th>Option type</th>
           <th>Description</th>
           <th>Example</th>
          </tr>

         </thead>

         <tbody class="tbody">
          <tr style="vertical-align: top;">
           <td>date_century_boundary</td>
           <td><span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span></td>
           <td>The threshold by which a 2-digit year is determined to be in
           the current century or in the next century. Equivalent to II_DATE_CENTURY_BOUNDARY. </td>
           <td>50</td>
          </tr>

          <tr style="vertical-align: top;">
           <td>group</td>
           <td><span class="type"><a href="language.types.string.html" class="type string">string</a></span></td>
           <td>Specifies the group ID of the user, equivalent to the &quot;-G&quot;
           flag</td>
           <td>payroll</td>
          </tr>

          <tr style="vertical-align: top;">
           <td>role</td>
           <td><span class="type"><a href="language.types.string.html" class="type string">string</a></span></td>
           <td>The role ID of the application. If a role password is
           required, the parameter value should be specified as &quot;role/password&quot;</td>
          </tr>

          <tr style="vertical-align: top;">
           <td>effective_user</td>
           <td><span class="type"><a href="language.types.string.html" class="type string">string</a></span></td>
           <td>The ingres user account being impersonated, equivalent to the &quot;-u&quot; flag</td>
           <td>another_user</td>
          </tr>

          <tr style="vertical-align: top;">
           <td>dbms_password</td>
           <td><span class="type"><a href="language.types.string.html" class="type string">string</a></span></td>
           <td>The internal database password for the user connecting to Ingres</td>
           <td>s3cr3t</td>
          </tr>

          <tr style="vertical-align: top;">
           <td>table_structure</td>
           <td><span class="type"><a href="language.types.string.html" class="type string">string</a></span></td>
           <td><p class="para">
             The default structure for new tables.
             Valid values for table_structure are:
            <ul class="itemizedlist">
             <li class="listitem"><span class="simpara">INGRES_STRUCTURE_BTREE</span></li>
             <li class="listitem"><span class="simpara">INGRES_STRUCTURE_HASH</span></li>
             <li class="listitem"><span class="simpara">INGRES_STRUCTURE_HEAP</span></li>
             <li class="listitem"><span class="simpara">INGRES_STRUCTURE_ISAM</span></li>
             <li class="listitem"><span class="simpara">INGRES_STRUCTURE_CBTREE</span></li>
             <li class="listitem"><span class="simpara">INGRES_STRUCTURE_CISAM</span></li>
             <li class="listitem"><span class="simpara">INGRES_STRUCTURE_CHASH</span></li>
             <li class="listitem"><span class="simpara">INGRES_STRUCTURE_CHEAP</span></li>
            </ul>
            </p>
           </td>
           <td>INGRES_STRUCTURE_BTREE</td>
          </tr>

          <tr style="vertical-align: top;">
           <td>index_structure</td>
           <td><span class="type"><a href="language.types.string.html" class="type string">string</a></span></td>
           <td><p class="para">
             The default structure for new secondary indexes. Valid values
           for index_structure are:
            <ul class="itemizedlist">
             <li class="listitem"><span class="simpara">INGRES_STRUCTURE_CBTREE</span></li>
             <li class="listitem"><span class="simpara">INGRES_STRUCTURE_CISAM</span></li>
             <li class="listitem"><span class="simpara">INGRES_STRUCTURE_CHASH</span></li>
             <li class="listitem"><span class="simpara">INGRES_STRUCTURE_BTREE</span></li>
             <li class="listitem"><span class="simpara">INGRES_STRUCTURE_HASH</span></li>
             <li class="listitem"><span class="simpara">INGRES_STRUCTURE_ISAM</span></li>
            </ul>
            </p>
           </td>
           <td>INGRES_STRUCTURE_HASH</td>
          </tr>

          <tr style="vertical-align: top;">
           <td>login_local</td>
           <td><span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span></td>
           <td>Determines how the connection user ID and password are
           used when a VNODE is included in the target database string.
           If set to TRUE, the user ID and password are used to locally access
           the VNODE, and the VNODE login information is used to establish the DBMS
           connection. If set to FALSE, the process user ID is used to access
           the VNODE, and the connection user ID and password are used in place
           of the VNODE login information to establish the DBMS connection.
           This parameter is ignored if no VNODE is included in the target
           database string. The default is FALSE.</td>
           <td>TRUE</td>
          </tr>

          <tr style="vertical-align: top;">
           <td>timezone</td>
           <td><span class="type"><a href="language.types.string.html" class="type string">string</a></span></td>
           <td>Controls the timezone of the session. If not set it will
           default to the value defined by II_TIMEZONE_NAME. If
           II_TIMEZONE_NAME is not defined, NA-PACIFIC (GMT-8 with Daylight
           Savings) is used.</td>
          </tr>

          <tr style="vertical-align: top;">
           <td>date_format</td>
           <td><span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span></td>
           <td><p class="para">Sets the allowable input and output format for Ingres dates.
           Defaults to the value defined by II_DATE_FORMAT. If II_DATE_FORMAT is
           not set the default date format is US, e.g. mm/dd/yy. Valid values
           for date_format are:
            <ul class="itemizedlist">
             <li class="listitem"><span class="simpara">INGRES_DATE_DMY</span></li>
             <li class="listitem"><span class="simpara">INGRES_DATE_FINISH</span></li>
             <li class="listitem"><span class="simpara">INGRES_DATE_GERMAN</span></li>
             <li class="listitem"><span class="simpara">INGRES_DATE_ISO</span></li>
             <li class="listitem"><span class="simpara">INGRES_DATE_ISO4</span></li>
             <li class="listitem"><span class="simpara">INGRES_DATE_MDY</span></li>
             <li class="listitem"><span class="simpara">INGRES_DATE_MULTINATIONAL</span></li>
             <li class="listitem"><span class="simpara">INGRES_DATE_MULTINATIONAL4</span></li>
             <li class="listitem"><span class="simpara">INGRES_DATE_YMD</span></li>
             <li class="listitem"><span class="simpara">INGRES_DATE_US</span></li>
            </ul>
            </p>
           </td>
           <td>INGRES_DATE_MULTINATIONAL4</td>
          </tr>

          <tr style="vertical-align: top;">
           <td>decimal_separator</td>
           <td><span class="type"><a href="language.types.string.html" class="type string">string</a></span></td>
           <td>The character identifier for decimal data</td>
           <td>&quot;,&quot;</td>
          </tr>

          <tr style="vertical-align: top;">
           <td>money_lort</td>
           <td><span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span></td>
           <td><p class="para">Leading or trailing currency sign. Valid values for money_lort
           are:
            <ul class="itemizedlist">
             <li class="listitem"><span class="simpara">INGRES_MONEY_LEADING</span></li>
             <li class="listitem"><span class="simpara">INGRES_MONEY_TRAILING</span></li>
            </ul>
            </p>
           </td>
           <td>INGRES_MONEY_TRAILING</td>
          </tr>

          <tr style="vertical-align: top;">
           <td>money_sign</td>
           <td><span class="type"><a href="language.types.string.html" class="type string">string</a></span></td>
           <td>The currency symbol to be used with the MONEY datatype</td>
           <td>€</td>
          </tr>

          <tr style="vertical-align: top;">
           <td>money_precision</td>
           <td><span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span></td>
           <td>The precision of the MONEY datatype</td>
           <td>3</td>
          </tr>

          <tr style="vertical-align: top;">
           <td>float4_precision</td>
           <td><span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span></td>
           <td>Precision of the FLOAT4 datatype</td>
           <td>10</td>
          </tr>

          <tr style="vertical-align: top;">
           <td>float8_precision</td>
           <td><span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span></td>
           <td>Precision of the FLOAT8 data</td>
           <td>10</td>
          </tr>

          <tr style="vertical-align: top;">
           <td>blob_segment_length</td>
           <td><span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span></td>
           <td>The amount of data in bytes to fetch at a time when retrieving
           BLOB or CLOB data, defaults to 4096 bytes when not explicitly set</td>
           <td>8192</td>
          </tr>

         </tbody>
        
       </table>

      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.ingres-connect-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns a Ingres link resource on success 或者在失败时返回 <strong><code>FALSE</code></strong>
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.ingres-connect-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-1298">
    <p><strong>Example #1 Open a connection to an Ingres database</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$link&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ingres_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">"mydb"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"user"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"pass"</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;or&nbsp;die(</span><span style="color: #DD0000">"Could&nbsp;not&nbsp;connect"</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #DD0000">"Connected&nbsp;successfully"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">ingres_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$link</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.ingres-connect-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="ingres_pconnect.html" class="function" rel="rdfs-seeAlso">ingres_pconnect()</a> - Open a persistent connection to an Ingres database</span></li>
    <li class="member"><span class="function"><a href="ingres_close.html" class="function" rel="rdfs-seeAlso">ingres_close()</a> - Close an Ingres database connection</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>